package com.gxa.hotel.admin.controller;

import com.gxa.hotel.admin.service.RoomStateService;
import com.gxa.hotel.admin.service.RoomsService;
import com.gxa.hotel.core.common.JsonResult;
import com.gxa.hotel.core.pojo.domain.RoomServices;
import com.gxa.hotel.core.pojo.domain.RoomState;
import com.gxa.hotel.core.pojo.domain.Rooms;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@Api
@RequestMapping("/room")
public class RoomsController {

    @Autowired
    RoomStateService roomStateService;

    @Autowired
    RoomsService roomsService;

    @ApiOperation("房型首页列表")
    @PostMapping("/list")
    public Map selectByDate(String date){
        List<RoomState> roomStates = roomStateService.selectByDate(date);

        JsonResult jsonResult=new JsonResult();
        jsonResult.setCode("1");
        jsonResult.setData(roomStates);
        return jsonResult.getMap();
    }

    @ApiOperation("房型详细信息")
    @PostMapping("/roomdetail")
    public Map selectByName(String name){

        Rooms rooms = roomsService.selectByName(name);
        JsonResult jsonResult=new JsonResult();
        jsonResult.setCode("1");
        jsonResult.setData(rooms);

        return jsonResult.getMap();
    }
}
